package com.zhang.quartz;

import com.zhang.entity.vo.ExecuteCommandBody;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

import static com.zhang.common.Constant.*;

/**
 * User: 张
 * Date: 2024-11-28
 * Time: 21:15
 * Description:
 */
@Component
public class TestJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        ExecuteCommandBody executeCommandBody = new ExecuteCommandBody(
                (Integer) jobDataMap.get(SERVER_ID),
                (Integer) jobDataMap.get(SCRIPT_TEMPLATE_ID),
                (Integer) jobDataMap.get(EXECUTE_FREQUENCY)
        );
        System.out.println("------------------------------");
        System.out.println("定时任务测试类");
        System.out.println(jobExecutionContext.toString());
        System.out.println(executeCommandBody.toString());
        System.out.println("------------------------------");
    }
}
